package com.baseframe.system.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baseframe.system.entity.BaseMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baseframe.system.entity.vo.BaseMenuVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**

* @description 针对表【base_menu(菜单表)】的数据库操作Mapper
* @createDate 2023-06-20 19:19:35
* @Entity com.baseframe.system.entity.BaseMenu
*/
public interface BaseMenuMapper extends BaseMapper<BaseMenu> {

    @Select("select bm.* from base_menu as bm left join  base_menu_role as bms on bm.id = bms.menu_id left join base_role as br on bms.role_id = br.id where bm.is_deleted = 0 and br.id = #{roleId} ;")
    List<BaseMenu> getMenuByRoleId(@Param("roleId") Long roleId);

    @Select("<script>" +
            "select id, name, parent, icon, type, router, sort, remarks, create_by, create_time, update_by, update_time, is_deleted from base_menu " +
            "<where>" +
            "is_deleted = 0 " +
            "and parent = null " +
            "<if test=\" menuName!=null &amp;&amp; menuName !='' \">" +
            "and name like concat('%',#{menuName},'%')" +
            "</if>" +
            "</where>" +
            "</script>")
    Page<BaseMenuVO> menuPageList(Page<BaseMenuVO> page, @Param("menuName") String menuName);
}




